/******************************************************************************/
/*                                                                            */
/*  Copyright (c) 2009: ngi-central.org                                       */
/*  All rights reserved.                                                      */
/*                                                                            */
/******************************************************************************/


#include <boost/test/unit_test.hpp>

#include "..\..\include\sgl\unnormalized_moments.h"

BOOST_AUTO_TEST_SUITE( unnormalized_moments )


BOOST_AUTO_TEST_CASE( unnormalized_moments__default_constructor )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m00() == 0 );
	BOOST_CHECK( a.m10() == 0 );
	BOOST_CHECK( a.m01() == 0 );
	BOOST_CHECK( a.m20() == 0 );
	BOOST_CHECK( a.m11() == 0 );
	BOOST_CHECK( a.m02() == 0 );
	BOOST_CHECK( a.m30() == 0 );
	BOOST_CHECK( a.m21() == 0 );
	BOOST_CHECK( a.m12() == 0 );
	BOOST_CHECK( a.m03() == 0 );

	sgl::unnormalized_moments<> b(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	BOOST_CHECK( b.m00() == 1 );
	BOOST_CHECK( b.m10() == 2 );
	BOOST_CHECK( b.m01() == 3 );
	BOOST_CHECK( b.m20() == 4 );
	BOOST_CHECK( b.m11() == 5 );
	BOOST_CHECK( b.m02() == 6 );
	BOOST_CHECK( b.m30() == 7 );
	BOOST_CHECK( b.m21() == 8 );
	BOOST_CHECK( b.m12() == 9 );
	BOOST_CHECK( b.m03() == 10 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__copy_constructor )
{
	sgl::unnormalized_moments<> a(
		sgl::unnormalized_moments<>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.m10() == 2 );
	BOOST_CHECK( a.m01() == 3 );
	BOOST_CHECK( a.m20() == 4 );
	BOOST_CHECK( a.m11() == 5 );
	BOOST_CHECK( a.m02() == 6 );
	BOOST_CHECK( a.m30() == 7 );
	BOOST_CHECK( a.m21() == 8 );
	BOOST_CHECK( a.m12() == 9 );
	BOOST_CHECK( a.m03() == 10 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__copy_assignment )
{
	sgl::unnormalized_moments<> a;
	a = sgl::unnormalized_moments<>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.m10() == 2 );
	BOOST_CHECK( a.m01() == 3 );
	BOOST_CHECK( a.m20() == 4 );
	BOOST_CHECK( a.m11() == 5 );
	BOOST_CHECK( a.m02() == 6 );
	BOOST_CHECK( a.m30() == 7 );
	BOOST_CHECK( a.m21() == 8 );
	BOOST_CHECK( a.m12() == 9 );
	BOOST_CHECK( a.m03() == 10 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__swap )
{
	sgl::unnormalized_moments<> a(
		sgl::unnormalized_moments<>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
	sgl::unnormalized_moments<> b;

	a.swap(b);

	BOOST_CHECK( a.m00() == 0 );
	BOOST_CHECK( a.m10() == 0 );
	BOOST_CHECK( a.m01() == 0 );
	BOOST_CHECK( a.m20() == 0 );
	BOOST_CHECK( a.m11() == 0 );
	BOOST_CHECK( a.m02() == 0 );
	BOOST_CHECK( a.m30() == 0 );
	BOOST_CHECK( a.m21() == 0 );
	BOOST_CHECK( a.m12() == 0 );
	BOOST_CHECK( a.m03() == 0 );
	BOOST_CHECK( b.m00() == 1 );
	BOOST_CHECK( b.m10() == 2 );
	BOOST_CHECK( b.m01() == 3 );
	BOOST_CHECK( b.m20() == 4 );
	BOOST_CHECK( b.m11() == 5 );
	BOOST_CHECK( b.m02() == 6 );
	BOOST_CHECK( b.m30() == 7 );
	BOOST_CHECK( b.m21() == 8 );
	BOOST_CHECK( b.m12() == 9 );
	BOOST_CHECK( b.m03() == 10 );

	b.swap(a);

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.m10() == 2 );
	BOOST_CHECK( a.m01() == 3 );
	BOOST_CHECK( a.m20() == 4 );
	BOOST_CHECK( a.m11() == 5 );
	BOOST_CHECK( a.m02() == 6 );
	BOOST_CHECK( a.m30() == 7 );
	BOOST_CHECK( a.m21() == 8 );
	BOOST_CHECK( a.m12() == 9 );
	BOOST_CHECK( a.m03() == 10 );
	BOOST_CHECK( b.m00() == 0 );
	BOOST_CHECK( b.m10() == 0 );
	BOOST_CHECK( b.m01() == 0 );
	BOOST_CHECK( b.m20() == 0 );
	BOOST_CHECK( b.m11() == 0 );
	BOOST_CHECK( b.m02() == 0 );
	BOOST_CHECK( b.m30() == 0 );
	BOOST_CHECK( b.m21() == 0 );
	BOOST_CHECK( b.m12() == 0 );
	BOOST_CHECK( b.m03() == 0 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m00 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m00() == 0 );

	a.m00() = 1;

	BOOST_CHECK( a.m00() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m10 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m10() == 0 );

	a.m10() = 1;

	BOOST_CHECK( a.m10() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m01 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m01() == 0 );

	a.m01() = 1;

	BOOST_CHECK( a.m01() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m20 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m20() == 0 );

	a.m20() = 1;

	BOOST_CHECK( a.m20() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m11 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m11() == 0 );

	a.m11() = 1;

	BOOST_CHECK( a.m11() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m02 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m02() == 0 );

	a.m02() = 1;

	BOOST_CHECK( a.m02() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m30 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m30() == 0 );

	a.m30() = 1;

	BOOST_CHECK( a.m30() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m21 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m21() == 0 );

	a.m21() = 1;

	BOOST_CHECK( a.m21() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m12 )
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m12() == 0 );

	a.m12() = 1;

	BOOST_CHECK( a.m12() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__m03)
{
	sgl::unnormalized_moments<> a;

	BOOST_CHECK( a.m03() == 0 );

	a.m03() = 1;

	BOOST_CHECK( a.m03() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__operator_equality )
{
	sgl::unnormalized_moments<> a;
	sgl::unnormalized_moments<> b;

	BOOST_CHECK( a == b );

	sgl::unnormalized_moments<> c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
	sgl::unnormalized_moments<> d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	BOOST_CHECK( c == d );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__operator_inequality )
{
	sgl::unnormalized_moments<> a;
	sgl::unnormalized_moments<> b(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	BOOST_CHECK( a != b );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm10 )
{
	sgl::unnormalized_moments<> a;

	a.m10() = 2;
	BOOST_CHECK_THROW( a.calculate_nm10(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm10() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm01 )
{
	sgl::unnormalized_moments<> a;

	a.m01() = 2;
	BOOST_CHECK_THROW( a.calculate_nm01(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm01() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm20 )
{
	sgl::unnormalized_moments<> a;

	a.m20() = 2;
	BOOST_CHECK_THROW( a.calculate_nm20(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm20() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm11 )
{
	sgl::unnormalized_moments<> a;

	a.m11() = 2;
	BOOST_CHECK_THROW( a.calculate_nm11(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm11() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm02 )
{
	sgl::unnormalized_moments<> a;

	a.m02() = 2;
	BOOST_CHECK_THROW( a.calculate_nm02(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm02() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm30 )
{
	sgl::unnormalized_moments<> a;

	a.m30() = 2;
	BOOST_CHECK_THROW( a.calculate_nm30(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm30() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm21 )
{
	sgl::unnormalized_moments<> a;

	a.m21() = 2;
	BOOST_CHECK_THROW( a.calculate_nm21(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm21() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm12 )
{
	sgl::unnormalized_moments<> a;

	a.m12() = 2;
	BOOST_CHECK_THROW( a.calculate_nm12(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm12() == 1 );
}

BOOST_AUTO_TEST_CASE( unnormalized_moments__calculate_nm03)
{
	sgl::unnormalized_moments<> a;

	a.m03() = 2;
	BOOST_CHECK_THROW( a.calculate_nm03(), sgl::precondition_violated );

	a.m00() = 2;

	BOOST_CHECK( a.calculate_nm03() == 1 );
}

BOOST_AUTO_TEST_SUITE_END()

